package com.gupao.gupaoeduvippattern.javaBase.a4fanshe.demo01;

import java.lang.reflect.Method;

/**
 * @author Administrator
 * @date 2020-12-22 22:23
 */
public class Demo01 {

    public static void main(String[] args) throws Exception {
        //获取一个类对象
        Class<User> clazz = User.class;

        //获取类对象的属性或者方法
        System.out.println(clazz.getName());
        System.out.println(clazz.getPackageName());
        System.out.println(clazz.getClassLoader());
        System.out.println(clazz.getSuperclass());

        //获取一个实例对象
        User user = clazz.newInstance();

        //获取对象中的方法
        Method method = clazz.getDeclaredMethod("jump");
        //通过反射执行方法
        method.invoke(user);


    }

}
